package com.listen.common;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;


public class LoadNewDaAn {
	
	/*INSTANCE;
	
	private ConfigUtils(){
		System.out.println("构造函数被调用");
    }*/
	
	public static Map<String,Object> resultMap = new ConcurrentHashMap<String,Object>();
	
	private static Properties properties = new Properties();
	
	private static final String SYSTEM_CONFIG_NAME = "daan_new.properties";

	public static void load(String path){
		System.out.println("init t1 ... "+path);
		try {
			properties.load(LoadNewDaAn.class.getResourceAsStream("/" + path));
			Object[] objs = properties.keySet().toArray();
			for(int i=0;i<objs.length;i++){
				resultMap.put(objs[i]+"", properties.get(objs[i]).toString());
			}
			
		} catch (FileNotFoundException e) {
			System.out.println("The config file daan_new.properties does not exist.");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("Failed to load the settings from the file: daan_new.properties");
			e.printStackTrace();
	    }
	}
	
	static {
    	load(SYSTEM_CONFIG_NAME);
    }
	
    public static String getConfig(String key) {
    	return properties.getProperty(key);
    }
    
    public static void main(String args[]){
    	System.out.println(LoadNewDaAn.getConfig("575"));
    }
}
